@@ -39,7 +39,7 @@ module Agents |
||
39 | 39 |
|
40 | 40 |
def receive_web_request(params, method, format) |
41 | 41 |
secret = params.delete('secret') |
42 |
- return ["Please use POST requests only", 401] unless method == "post" |
|
42 |
+ return ["Please use POST requests only", 401] unless method == "post" || options['verbs'] |
|
43 | 43 |
return ["Not Authorized", 401] unless secret == interpolated['secret'] |
44 | 44 |
|
45 | 45 |
[payload_for(params)].flatten.each do |payload| |
@@ -60,6 +60,28 @@ describe Agents::WebhookAgent do |
||
60 | 60 |
|
61 | 61 |
end |
62 | 62 |
|
63 |
+ context "accepting get and post" do |
|
64 |
+ |
|
65 |
+ before { agent.options['verbs'] = 'get;post' } |
|
66 |
+ |
|
67 |
+ it "should accept GET" do |
|
68 |
+ out = nil |
|
69 |
+ expect { |
|
70 |
+ out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "get", "text/html") |
|
71 |
+ }.to change { Event.count }.by(1) |
|
72 |
+ expect(out).to eq(['Event Created', 201]) |
|
73 |
+ end |
|
74 |
+ |
|
75 |
+ it "should accept POST" do |
|
76 |
+ out = nil |
|
77 |
+ expect { |
|
78 |
+ out = agent.receive_web_request({ 'secret' => 'foobar', 'some_key' => payload }, "post", "text/html") |
|
79 |
+ }.to change { Event.count }.by(1) |
|
80 |
+ expect(out).to eq(['Event Created', 201]) |
|
81 |
+ end |
|
82 |
+ |
|
83 |
+ end |
|
84 |
+ |
|
63 | 85 |
end |
64 | 86 |
|
65 | 87 |
end |